package com.xmlit.project.client;

import com.smartgwt.client.data.DataSource;  
import com.smartgwt.client.data.fields.DataSourceFloatField;  
import com.smartgwt.client.data.fields.DataSourceIntegerField;  
import com.smartgwt.client.data.fields.DataSourceTextField;  
import com.smartgwt.client.widgets.tree.TreeGridField;
  
public class EmployeeXmlDS extends DataSource {  
	  
    private static EmployeeXmlDS instance = null;  
  
    public static EmployeeXmlDS getInstance() {  
        if (instance == null) {  
            instance = new EmployeeXmlDS("employeesDS");  
        }  
        return instance;  
    }  
  
    public EmployeeXmlDS(String id) {  
  
        setID(id);  
        setTitleField("Name");  
        setRecordXPath("/List/employee");  
       DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);  
       nameField.setPrimaryKey(true);
       /*        DataSourceIntegerField employeeIdField = new DataSourceIntegerField("EmployeeId", "Employee ID");  
        employeeIdField.setPrimaryKey(true);  
        employeeIdField.setRequired(true);  
  
        DataSourceIntegerField reportsToField = new DataSourceIntegerField("ReportsTo", "Manager");  
        reportsToField.setRequired(true);  
        reportsToField.setForeignKey(id + ".EmployeeId");  
        reportsToField.setRootValue("1");  */
/*        DataSourceTextField jobField = new DataSourceTextField("Job", "Title", 128);  
        DataSourceTextField emailField = new DataSourceTextField("Email", "Email", 128);  
        DataSourceTextField statusField = new DataSourceTextField("EmployeeStatus", "Status", 40);  
        DataSourceFloatField salaryField = new DataSourceFloatField("Salary", "Salary");  
        DataSourceTextField orgField = new DataSourceTextField("OrgUnit", "Org Unit", 128);  
        DataSourceTextField genderField = new DataSourceTextField("Gender", "Gender", 7);  
*/     
		
        DataSourceTextField typeField = new DataSourceTextField("Type", "Type", 80);  
        DataSourceTextField minField = new DataSourceTextField("Min", "Min", 80);  
        DataSourceTextField maxField = new DataSourceTextField("Max", "Max", 80);  

  
  
        setFields(nameField, /*employeeIdField, reportsToField,*/ typeField, minField, maxField);  
  
        setDataURL("ds/test_data/employees.data.xml");  
        setClientOnly(true);  
    }  
}  